DEFINE VARIABLE qty_all_ld LIKE ld_qty_all.

FOR EACH wod_det WHERE wod_qty_req = 0 AND wod_qty_iss = 0 
                   AND (wod_qty_all <> 0 OR wod_qty_pick <> 0),
    EACH wo_mstr WHERE wo_lot = wod_lot AND wo_status <> "c"
    BREAK BY wod_part BY wod_nbr:

    RUN get_ld_allocated(INPUT wod_part,INPUT wo_site, OUTPUT qty_all_ld).

    DISP wod_nbr wod_part wo_site wo_status 
         wod_qty_req wod_qty_iss wod_qty_all wod_qty_pick 
         qty_all_ld WHEN LAST-OF(wod_part)
         wod_qty_ret
        WITH STREAM-IO WIDTH 200.

END.


PROCEDURE get_ld_allocated.
   DEFINE INPUT PARAMETER part AS CHARACTER.
   DEFINE INPUT PARAMETER site AS CHARACTER.
   DEFINE OUTPUT PARAMETER qty_all AS DECIMAL.
   DEFINE BUFFER ld FOR ld_det.

   FOR EACH ld WHERE ld_part = part AND ld_site = site:
       ACCUMULATE ld_qty_all (TOTAL).
       qty_all = ACCUM TOTAL ld_qty_all.
   END.

   

END.
